﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Goal : MonoBehaviour
{
    public static Goal Instance
    {
        get
        {
            if (_Instance == null)
            {
                _Instance = GameObject.FindObjectOfType<Goal>();
            }
            if (!_Instance)
            {
                GameObject obj = new GameObject("Goal");
                _Instance = obj.AddComponent<Goal>();
            }
            return _Instance;
        }
        set
        {
            _Instance = value;
        }
    }
    private static Goal _Instance;

    public Transform trans;

    private void Awake()
    {
        
    }
    // Start is called before the first frame update
    void Start()
    {
        trans = this.GetComponent<Transform>();
        Vector3 goalpos;
        if (ConstOfMap.loadgame)
        {
            goalpos = new Vector3(ConstOfMap.save.goalPos.x, ConstOfMap.save.goalPos.y, 0f);
        }
        else goalpos = Function.LogicPosToWorldPos(ConstOfMap.initGoalPos);
        goalpos.z = goalpos.y * 0.1f;
        trans.position = goalpos;
    }

    // Update is called once per frame
    void Update()
    {

    }
    public Vector2 GetGoalPos()
    {
        return trans.position;
    }
}
